%% Rotate a triangle
% Rotate a triangle through 90*, on at a time
tic
clear;
%% Define shapes
% This is our triangle.
tri = [0,0;
       2,-1; 
       0,4;
       -2,-1];

%% Setup Figure
fig=figure();
hold on;
axis([-4*2 4*2 -3*2 3*2]);

%% Figure config
set(fig,'Position',[200 200 640 480]);

%% Axis config
% Get the current axes
fig_axis=get(fig,'CurrentAxes');
% Set axes to use pixels
set(fig_axis,'Units','pixels');
set(fig_axis,'Position',[0 0 640 480+1]);

%% 
% Dummie fill for first delete
h1=fill(0,0,'b');

%% Loop
for i=1:(1*60*30)
    tri=poly_rotate2(tri,-1,2,0.5);
    tri=poly_rotate2(tri,-.5);
    delete(h1);
    h1=fill(tri(:,1),tri(:,2),'b');
    M(i)=getframe;
end

%movie2avi(M,'mov','FPS',30,'compression','none');
toc